package lhdx5;


public class Shangchangyin {
    String diZ;
    String minC;

    Shangchang[] b = new Shangchang[100];
    int k = 0;

    public boolean adds(String hyh, String xinm, String shoj, int a) {
        if (k >= b.length) {
            System.out.println("人已满");
            return false;
        }
        for (int i = 0; i < k; i++) {
            if (b[i].hyh.equals(hyh)) {
                System.out.println("已重复");
                return true;
            }
        }

        b[k] = new Shangchang();
        b[k].hyh = hyh;
        b[k].xinm = xinm;
        b[k].shoj = shoj;
        b[k].a = a;
        b[k].show();
        k++;
        return true;

    }

    public boolean inc(String hyh, int c) {
        for (int i = 0; i < k; i++) {
            if (b[i].hyh.equals(hyh)) {
                b[i].a = b[i].a + c;
                return true;
            }
        }
        return false;
    }

    public String duihuan(String hyh, int A) {
        for (int i = 0; i < k; i++) {
            if (b[i].hyh.equals(hyh)) {
                if (A == 1 && b[i].a >= 100) {
                    b[i].a = b[i].a - 100;
                    return "兑换成功";
                }
                if (A == 2 && b[i].a >= 400) {
                    b[i].a =b[i].a - 400;
                    return "兑换成功";
                }
                if (A == 3 && b[i].a >= 1000) {
                    b[i].a = b[i].a - 1000;
                    return "兑换成功";
                }
            }else {
                return null;
            }
        }
        return null;
    }
    public void changxi(){
        System.out.println("会员信息如下：");
        for (int i=0;i<k;i++){
            System.out.println(b[i].hyh+"  "+b[i].xinm+"  "+b[i].shoj+"  "+b[i].a);
        }
    }

}
